
<script>
function check_file(typ,pole,blad){
        var str=document.getElementById(pole).value.toUpperCase();
        var suffix=typ;
        
        if(!(str.indexOf(suffix, str.length - suffix.length) !== -1)){
         document.getElementById(pole).value='';
         document.getElementById(blad).style.display = "block";   
        }
	else
	{
	document.getElementById(blad).style.display = "none";
	}
    }

</script>

<form action="" method="post" enctype="multipart/form-data" >
Nazwa portfolio
<br />
<input type="text" name="nazwa_port" class="input_style"/>
<br />
Słowa kluczowe oddzielone znakiem spacji
<br />
<textarea name="keywords" cols="30" rows="5" class="input_style"></textarea>
<br />
Plik favicon 
<br />
<input name="favicon" type="file" onchange="check_file('.ICO','favicon','blad_fav')" id="favicon" />
Co to jest?
<div id="blad_fav" style="display: none">Błędny format pliku. Wybierz plik o rozszerzeniu .ico</div>
<br />
Opis twojej strony
<br />
<textarea name="opis" cols="30" rows="5" class="input_style"></textarea>
<br />
Plik kaskadowego arkusza stylów
<br />
<input name="css_file" type="file" onchange="check_file('.CSS','css_file','blad_css')" id="css_file"/>
<div id="blad_css" style="display: none">Błędny format pliku. Wybierz plik o rozszerzeniu .css</div>
<br />
<input name="submit" type="submit" value="Zatwierdź" />
</form>

<?php 
	
	  
	if($_POST!=NULL){
	
	$setup->set_nazwa($_POST["nazwa_port"]);
	$setup->set_keywords($_POST["keywords"]);
	$setup->set_opis($_POST["opis"]);
	
	$file_info = new finfo(FILEINFO_MIME);
	
	if($_FILES!=NULL)

	
		if($file_info->file($_FILES['favicon']['tmp_name'], FILEINFO_MIME_TYPE)=="image/x-ico")
		{
			move_uploaded_file($_FILES['favicon']['tmp_name'],"images/user_favicon/".$_FILES['favicon']['name']); 
			$setup->set_favicon_src("images/user_favicon/".$_FILES['favicon']['name']);	
		}
		else
		{
			echo "Błędny format pliku favicon";
		}

		if($file_info->file($_FILES['css_file']['tmp_name'], FILEINFO_MIME_TYPE)=="text/x-c")
		{
			move_uploaded_file($_FILES['css_file']['tmp_name'],"css/user_css/".$_FILES['css_file']['name']); 
			$setup->set_css_src("css/user_css/".$_FILES['css_file']['name']);
		}
		else
		{
			echo "Błędny format pliku arkusza styli";
		}

	$kluczowe = $setup->get_keywords();
		
	$kluczowe_string = "";
	foreach($kluczowe as $value)
    	{
		$kluczowe_string .= $value.", ";
	
	}
	
	$kluczowe_string = substr($kluczowe_string,0,strlen($kluczowe_string)-2);	
	
	$tab=Array ( 'config' => Array ( 
                                    'head_title' => $setup->get_nazwa(), 
                                    'head_desc' => $setup->get_opis(),
                                    'head_keywords' => $kluczowe_string,
                                    'head_favicon' => $setup->get_favicon_src(),
                                    'head_css' => $setup->get_css_src(),
				    'head_ok' => 1
                                       ));
         $n->w2i($tab, "setup.ini",TRUE);
	}

        $sini=parse_ini_file("setup.ini",1);
        if($sini['config']['head_ok'] == 1){
            echo '<form action="index.php?token='.md5($results[3]['file']).'" method="post" enctype="multipart/form-data" >';
            //echo "<input type='hidden' name='page' value='1' /> ";
            echo " <input type='submit' ".$str." value='dalej' /></form>";
        }
 ?>
